<include file="public:header"/>
<include file="public:left"/>
<style>
    .table span{display: block;width: 100%}
</style>
     <section>
      <h2><strong>服务产品价格编辑（点击数字即可修改）</strong><a style="float: right" href="javascript:void(0)" onclick="history.go(-1)">返回上一页</a></h2>
         <table class="table">
             <tr>
                 <th style="width: 200px">日期</th>
                 <th style="width: 200px">原价</th>
                 <th style="width: 200px">银卡价</th>
                 <th style="width: 200px">金卡价</th>
                 <th style="width: 200px">珀金价</th>
                 <th style="width: 200px">黑金卡价</th>
                 <th style="width: 200px">数量</th>
             </tr>
             <volist name="list" id="vo">
                 <tr data-id="{$vo.id}">
                     <td><?php echo date("Y-m-d",$vo['roomdate']);?></td>
                     <td><span>{$vo.oprice}</span><input  type="hidden"  data-type="oprice" value="{$vo.oprice}"></td>
                     <td><span>{$vo.price1}</span><input type="hidden"  data-type="price1" value="{$vo.price1}"></td>
                     <td><span>{$vo.price2}</span><input type="hidden"  data-type="price2" value="{$vo.price2}"></td>
                     <td><span>{$vo.price3}</span><input type="hidden"  data-type="price3" value="{$vo.price3}"></td>
                     <td><span>{$vo.price4}</span><input type="hidden"  data-type="price4" value="{$vo.price4}"></td>
                     <td><span>{$vo.num}</span><input type="hidden"  data-type="num" value="{$vo.num}"></td>
                 </tr>
             </volist>

         </table>
         {$list->render()}
     </section>
<script>
    $(".table span").click(function(){
        $(this).hide();
        $(this).siblings("input").prop("type","number");
    });
    $(".table input").blur(function(){
        var str=$(this);
        var id=$(this).parents("tr").data("id");
        var type=$(this).data('type');
        var a = new Number($(this).val());
        var num=a.toFixed(2);
        $.post("{:url('goods/updateprice')}",{id:id,type:type,num:num},function(result){
            if(result==1) {
                str.prop("type", "hidden");
                str.val(num);
                str.siblings("span").show();
                str.siblings("span").html(num);
            }else{
                alert('系统繁忙，稍后再试');
            }
        });
    })
</script>